class Solution:
    def numTrees(self, n: int) -> int:
        node_list = [1 for i in range(0, n+1)]
        for i in range(2, n+1):
            node_list[i] = sum([node_list[j] * node_list[i-j-1] for j in range(i)])
        return node_list[-1]